home *** CD-ROM | disk | FTP | other *** search
/ Disc to the Future 2 / Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin / MAC / THINKC / 4_0 / LIFER__ / PROTO / P / MAIN_LIF.C next >
C/C++ Source or Header  |  1991-07-23  |  22KB  |  554 lines

  1. /* Main_Life */
  2.  
  3. /* Program name:  Main_Life.c   */
  4. /* Function:  This is the main module for this program.   */
  5. /* History: 7/23/91 Original by Prototyper 3.0   */
  6.  
  7. #include "PCommonLife.h"    /* Common */
  8. #include "Common_Life.h"    /* Common */
  9. #include "PUtils_Life.h"    /* General Utilities */
  10. #include "Utils_Life.h"    /* General Utilities */
  11.  
  12. #include "InitExitLife.h"    /* Init, Exit handlers */
  13. #include "EventsLife.h"    /* Extra event handlers */
  14.  
  15. #include "PA_Life_Alert.h"    /* Alert */
  16. #include "PD_LIFE_INPUT.h"    /* Modal Dialog */
  17. #include "PMD_LIFE_WINDOW.h"    /* Modeless Dialog */
  18. #include "PIMenu_Life.h"    /* Init menus */
  19. #include "PDoMenuLife.h"    /* Handle menus */
  20.  
  21. Boolean        DoIt;                                                            /* Flag saying an event is ready */
  22. short    code;                                                                 /* Determine event type */
  23. WindowPtr    whichWindow;                                                /* See which window for event */
  24. long    mResult;                                                              /* Menu list and item selected values */
  25. short    theMenu,theItem;                                                  /* Menu list and item selected */
  26. Boolean    Is_A_Dialog;                                                     /* Flag for modless dialogs */
  27. short    charCode, itemHit;                                                 /* For modeless dialogs*/
  28. char    ch;                                                                     /* Key pressed in Ascii */
  29. Boolean        DoTheModelessEvent, CmdDown;                          /* For modeless dialogs*/
  30. WindowPeek    thePeeked;                                                  /* For modeless dialogs*/
  31.  
  32. /* Prototypes */
  33.  
  34. /* See if WaitNextEvent is available */
  35. static Boolean WNEIsImplemented(void);
  36.  
  37. /* Check for user events */
  38. static void Handle_User_Event(void);
  39.  
  40. /* Handle key strokes */
  41. static void DoKeyEvent(void);
  42.  
  43. /* Handle a diskette inserted */
  44. static void DoDiskEvent(void);
  45.  
  46. /* Handle a window being resized */
  47. static void DoGrow(WindowPtr whichWindow);
  48.  
  49. /* Handle a window being dragged */
  50. static void DoDrag(WindowPtr whichWindow);
  51.  
  52. /* Handle a window goaway box */
  53. static void DoGoAway(WindowPtr whichWindow);
  54.  
  55. /* Handle a hit in the window */
  56. static void DoInContent(WindowPtr whichWindow);
  57.  
  58. /* Handle an update to the window */
  59. static void DoUpdate(void);
  60.  
  61. /* Handle an activate of the window */
  62. static void DoActivate(void);
  63.  
  64.  
  65.  
  66. /* MAIN entry point */
  67. void main(void);
  68.  
  69.  
  70.  
  71. /* ======================================================= */
  72.  
  73. /* Routine: WNEIsImplemented */
  74. /* Purpose: See if the MultiFinder trap, WaitNextEvent, is available */
  75.  
  76. Boolean WNEIsImplemented()                                               /* See if WaitNextEvent is available */
  77. {
  78.         #define    WNETrapNumber    0xA860                             /* The expected trap number */
  79.         SysEnvRec    theWorld;                                              /* Environment record */
  80.         OSErr    discardError;                                                /* Error code returned */
  81.         Boolean    theWNEIsImplemented;                                   /* Value to return */
  82.  
  83.         HasColorQD = FALSE;                                                 /* Init to no color QuickDraw */
  84.         HasFPU = FALSE;                                                      /* Init to no floating point chip */
  85.         InTheForeground = TRUE;                                             /* Init to a foreground app */
  86.         discardError = SysEnvirons(1, &theWorld);                     /* Check how old this system is */
  87.         if (theWorld.machineType < 0)                                      /* Negative means really old */
  88.             theWNEIsImplemented = FALSE;                                 /* Really old ROMs, no WNE possible */
  89.         else
  90.             {
  91.                 theWNEIsImplemented = TrapAvailable(WNETrapNumber, ToolTrap);/* See if trap is there */
  92.                 HasColorQD = theWorld.hasColorQD;                         /* Flag for Color QuickDraw being available */
  93.                 HasFPU = theWorld.hasFPU;                                   /* Flag for Floating Point Math Chip being available */
  94.             }
  95.         return(theWNEIsImplemented);
  96. }
  97.  
  98. /* ======================================================= */
  99.  
  100. /* Routine: Handle_User_Event */
  101. /* Purpose: Check for user events */
  102.  
  103. void Handle_User_Event()                                                 /* Check for user events */
  104. {
  105.         UserEventRec    TheUserEvent;                                     /* The user event */
  106.  
  107.         GetUserEvent(&TheUserEvent);                                     /* Check for any user events */
  108.         if (TheUserEvent.ID != UserEvent_None)                          /* Only do if we have any */
  109.             {
  110.  
  111.                 switch (TheUserEvent.ID)                                     /* Key off the Event ID */
  112.                 {
  113.                         case UserEvent_Open_Window:                         /* Open a Window or Modeless dialog */
  114.                                 switch (TheUserEvent.ID2)                       /* Do the appropiate window */
  115.                                 {
  116.                                         case Res_D_LIFE_INPUT:
  117.                                                     PD_LIFE_INPUT();                 /* Open this modal dialog */
  118.                                                     break;
  119.                                         case Res_MD_LIFE_WINDOW:
  120.                                                     Open_LIFE_WINDOW();             /* Open this modeless dialog */
  121.                                                     break;
  122.                                         case Res_A_Life_Alert:
  123.                                                     PA_Life_Alert();                  /* Open this alert */
  124.                                                     break;
  125.                                         default:                                        /* Handle others */
  126.                                                     break;
  127.                                 }                                                      /* End of the switch */
  128.                                 break;
  129.  
  130.                         case UserEvent_Close_Window:                        /* Close a Window or Modeless dialog */
  131.                                 switch (TheUserEvent.ID2) {                     /* Do the appropiate window */
  132.                                         case Res_MD_LIFE_WINDOW: Close_LIFE_WINDOW(WPtr_LIFE_WINDOW);
  133.                                                     Close_LIFE_WINDOW(WPtr_LIFE_WINDOW);/* Close this modeless dialog */
  134.                                                     break;
  135.                                         default:                                        /* Handle others */
  136.                                                     break;
  137.                 }                                                                   /* End of the switch */
  138.  
  139.                 break;
  140.         default:                                                                 /* Not standard, must be program specific */
  141.                     Handle_UserEvent(&TheUserEvent);                     /* Let program specific handle it */
  142.                     break;
  143. }                                                                                /* End of switch */
  144.  
  145.     }                                                                             /* End of handling a user event */
  146. }
  147.  
  148. /* ======================================================= */
  149.  
  150. /* Routine: DoKeyEvent */
  151. /* Purpose: Handle a key pressed */
  152.  
  153. void DoKeyEvent()                                                           /* Handle key presses */
  154. {
  155.         short    charCode;                                                     /* Key code */
  156.         char    ch;                                                              /* Key pressed in Ascii */
  157.         long    mResult;                                                        /* Menu list and item, if a command key */
  158.         short    theMenu,theItem;                                            /* Menu list and item, if command key */
  159.  
  160.         if (HandleKey(&myEvent))                                           /* Allow for special key handling */
  161.             {
  162.  
  163.                 charCode = myEvent.message & charCodeMask;           /* Get the character */
  164.                 ch = (char)charCode;                                           /* Change it to ASCII */
  165.  
  166.                 if ((myEvent.modifiers / cmdKey) & 1)                     /* See if Command key is down */
  167.                     {
  168.                         mResult = MenuKey(ch);                                 /* See if a menu selection */
  169.                         theMenu = HiWord(mResult);                           /* Get the menu list number */
  170.                         theItem = LoWord(mResult);                            /* Get the menu item number */
  171.                         if (theMenu != 0)                                         /* See if a list was selected */
  172.                             Handle_My_Menu(theMenu, theItem);             /* Do the menu selection */
  173.  
  174.                         if (((ch == 'x') || (ch == 'X')) && (theInput != NIL))/* See if a standard Cut */
  175.                             TECut(theInput);                                       /* Handle a Cut in a TE area */
  176.                         if (((ch == 'c') || (ch == 'C')) && (theInput != NIL))/* See if a standard Copy */
  177.                             TECopy(theInput);                                     /* Handle a Copy in a TE area */
  178.                         if (((ch == 'v')  ||  (ch == 'V')) && (theInput != NIL))/* See if a standard Paste */
  179.                             TEPaste(theInput);                                    /* Handle a Paste in a TE area */
  180.                     }                                                                /* End of Command key special condition */
  181.                 else if (theInput != NIL)
  182.                     TEKey(ch,theInput);                                         /* Place the normal key stroke */
  183.  
  184.             }                                                                      /* End of Standard keystroke handling */
  185. }
  186.  
  187. /* ======================================================= */
  188.  
  189. /* Routine: DoDiskEvent */
  190. /* Purpose: Handle a diskette inserted */
  191.  
  192. void DoDiskEvent()                                                          /* Handle disk inserted */
  193. {
  194.         short    theError;                                                     /* Error returned from mount */
  195.  
  196.         if (HandleDisk(&myEvent))                                          /* Allow for special disk inserted handling */
  197.             {
  198.  
  199.                 if (HiWord(myEvent.message) != noErr)                     /* See if a diskette mount error */
  200.                     {                                                                /* due to unformatted diskette inserted */
  201.                         myEvent.where.h = ((screenBits.bounds.right - screenBits.bounds.left) / 2) - (304 / 2);/* Center horz */
  202.                         myEvent.where.v = ((screenBits.bounds.bottom - screenBits.bounds.top) / 3) - (104 / 2);/* Top 3ed vertically */
  203.                         InitCursor();                                              /* Make sure it has an arrow cursor */
  204.                         theError = DIBadMount(myEvent.where, myEvent.message);/* Let the OS handle the diskette */
  205.                     }
  206.  
  207.             }                                                                      /* End of Standard disk inserted handling */
  208. }
  209.  
  210. /* ======================================================= */
  211.  
  212. /* Routine: DoGrow */
  213. /* Purpose: Handle a window resize */
  214.  
  215. void DoGrow(whichWindow)                                                /* Handle a window being resized */
  216. WindowPtr    whichWindow;
  217. {
  218.         Rect    OldRect;                                                        /* Window rect before the grow */
  219.         Point    myPt;                                                         /* Point for tracking grow box */
  220.         Rect    GrowRect;                                                     /* Set the grow bounds */
  221.         long    mResult;                                                        /* Result from the grow */
  222.  
  223.         if (whichWindow != NIL)                                              /* See if we have a legal window */
  224.             {
  225.                 SetPort(whichWindow);                                        /* Get ready to draw in this window */
  226.  
  227.                 myPt = myEvent.where;                                       /* Get mouse position */
  228.                 GlobalToLocal(&myPt);                                        /* Make it relative */
  229.  
  230.                 OldRect = whichWindow->portRect;                         /* Save the rect before resizing */
  231.  
  232.                 SetRect(&GrowRect, 4, 4, (screenBits.bounds.right - screenBits.bounds.left)-4,  (screenBits.bounds.bottom - screenBits.bounds.top) - 4);/* l,t,r,b */
  233.                 mResult = GrowWindow(whichWindow, myEvent.where, &GrowRect);/* Grow it */
  234.                 SizeWindow(whichWindow, LoWord(mResult), HiWord(mResult), TRUE);/* Resize to result */
  235.  
  236.  
  237.                 SetPort(whichWindow);                                        /* Get ready to draw in this window */
  238.  
  239.                 myPt.h = whichWindow->portRect.right - whichWindow->portRect.left; /* Local right edge */
  240.                 myPt.v = whichWindow->portRect.bottom - whichWindow->portRect.top; /* Local bottom edge */
  241.  
  242.                 SetRect(&GrowRect, 0, myPt.v - 15, myPt.h + 15, myPt.v + 15); /* Position for horz scrollbar area */
  243.                 EraseRect(&GrowRect);                                       /* Erase old area */
  244.                 InvalRect(&GrowRect);                                        /* Flag us to update it */
  245.  
  246.                 SetRect(&GrowRect, myPt.h - 15, 0, myPt.h + 15, myPt.v + 15);  /* Position for vert scrollbar area */
  247.                 EraseRect(&GrowRect);                                       /* Erase old area */
  248.                 InvalRect(&GrowRect);                                        /* Flag us to update it */
  249.  
  250.                 DrawGrowIcon(whichWindow);                               /* Draw the grow Icon again */
  251.             }                                                                      /* End of (WhichWindow <> nil) */
  252. }
  253.  
  254. /* ======================================================= */
  255.  
  256. /* Routine: DoDrag */
  257. /* Purpose: Drag a window around */
  258.  
  259. void DoDrag( whichWindow)                                                /* Handle a window being dragged */
  260. WindowPtr    whichWindow;
  261. {
  262.         Rect    OldRect;                                                        /* Window rect before the drag */
  263.         Rect    tempRect;                                                     /* temporary rect */
  264.  
  265.         OldRect = whichWindow->portRect;                                /* Save the rect before resizing */
  266.  
  267.         tempRect = screenBits.bounds;                                     /* Get screen area,  l,t,r,b, drag area */
  268.         SetRect(&tempRect,tempRect.left+4,tempRect.top+4,tempRect.right-4,tempRect.bottom - 4);
  269.         DragWindow(whichWindow, myEvent.where, &tempRect);/* Drag the window */
  270.  
  271.         switch (GetWRefCon(whichWindow))                               /* Do the appropiate window */
  272.         {
  273.                 case Res_MD_LIFE_WINDOW:
  274.                             Moved_LIFE_WINDOW(&OldRect, whichWindow);/* Moved this modeless dialog */
  275.                             break;
  276.                 default:                                                           /* Handle others */
  277.                             break;
  278.         }                                                                         /* End of the switch */
  279.  
  280. }
  281.  
  282. /* ======================================================= */
  283.  
  284. /* Routine: DoGoAway */
  285. /* Purpose: Close a window */
  286.  
  287. void DoGoAway( whichWindow)                                           /* Handle a window goaway box */
  288. WindowPtr    whichWindow;
  289. {
  290.         Rect    OldRect;                                                        /* Window rect before the drag */
  291.         Rect    tempRect;                                                     /* temporary rect */
  292.  
  293.         if (TrackGoAway(whichWindow,myEvent.where) == TRUE)/* See if mouse released in GoAway box */
  294.             {                                                                      /* Handle the GoAway */
  295.                 switch (GetWRefCon(whichWindow))                         /* Do the appropiate window */
  296.                 {
  297.                         case Res_MD_LIFE_WINDOW:
  298.                                     Close_LIFE_WINDOW(whichWindow);/* Close this modeless dialog */
  299.                                     break;
  300.                         default:                                                     /* Handle others */
  301.                                     break;
  302.                 }                                                                   /* End of the switch */
  303.             }                                                                      /* End of TrackGoAway */
  304.  
  305. }
  306.  
  307. /* ======================================================= */
  308.  
  309. /* Routine: DoInContent */
  310. /* Purpose: Pressed in the content area */
  311.  
  312. void DoInContent( whichWindow)                                          /* Handle a hit in the window */
  313. WindowPtr    whichWindow;
  314. {
  315.  
  316.         if (whichWindow != FrontWindow())                                /* See if already selected or not, in front if selected */
  317.             SelectWindow(whichWindow);                                    /* Select this window to make it active */
  318.         else                                                                     /* If already in front the already selected */
  319.             {                                                                      /* Handle the press in the content */
  320.                 SetPort(whichWindow);                                        /* Get ready to draw in this window */
  321.             }                                                                      /* End of else */
  322.  
  323. }
  324.  
  325. /* ======================================================= */
  326.  
  327. /* Routine: DoUpdate */
  328. /* Purpose: Got an update event */
  329.  
  330. void DoUpdate()                                                              /* Handle an update to the window */
  331. {
  332.         WindowPtr    whichWindow;                                         /* See which window for event */
  333.  
  334.         whichWindow = (WindowPtr)myEvent.message;                 /* Get the window the update is for */
  335.  
  336.         BeginUpdate(whichWindow);                                         /* Set the clipping to the update area */
  337.         EndUpdate(whichWindow);                                           /* Return to normal clipping area */
  338. }
  339.  
  340. /* ======================================================= */
  341.  
  342. /* Routine: DoActivate */
  343. /* Purpose: Got an activate or deactivate event */
  344.  
  345. void DoActivate()                                                            /* Handle an activate of the window */
  346. {
  347.         Boolean    Do_An_Activate;                                         /* Flag to pass */
  348.         WindowPtr    whichWindow;                                         /* See which window for event */
  349.  
  350.         whichWindow = (WindowPtr)myEvent.message;                 /* Get the window the update is for */
  351.  
  352.         Do_An_Activate = ((myEvent.modifiers & 0x0001) != 0);/* Make sure it is Activate and not DeActivate */
  353. }
  354.  
  355. /* ======================================================= */
  356.  
  357.  
  358.  void main()                                                                  /* Start of main body */
  359. {
  360.  
  361.         MoreMasters();                                                       /* This reserves space for more handles */
  362.         MaxApplZone();                                                        /* Give us room for memory allocation */
  363.         InitGraf(&thePort);                                                   /* Quickdraw Init */
  364.         InitFonts();                                                             /* Font manager init */
  365.         InitWindows();                                                         /* Window manager init */
  366.         InitMenus();                                                            /* Menu manager init */
  367.         TEInit();                                                                 /* Text edit init */
  368.         InitDialogs(NIL);                                                       /* Dialog manager */
  369.  
  370.         FlushEvents ( everyEvent , 0 );                                     /* Clear out all events */
  371.         InitCursor();                                                           /* Make an arrow cursor */
  372.  
  373.         doneFlag = FALSE;                                                     /* Do not exit program yet */
  374.  
  375.         Init_My_Menus();                                                     /* Initialize menu bar */
  376.  
  377.         theInput = NIL;                                                         /* Init to no text edit selection active */
  378.  
  379.         SleepValue = 40;                                                      /* Set sleep value */
  380.         WNE = WNEIsImplemented();                                         /* See if WaitNextEvent is available */
  381.  
  382.         UserEventList = NIL;                                                 /* No user events yet */
  383.  
  384.         ApplInit_Life();                                                        /* Handle extra program initialization */
  385.  
  386.         I_PD_LIFE_INPUT();                                                  /* Initialize the modal dialog globals */
  387.         Init_LIFE_WINDOW();                                                 /* Initialize the modeless dialog routines */
  388.         I_PA_Life_Alert();                                                   /* Initialize the alert globals */
  389.  
  390.         PD_LIFE_INPUT();                                                     /* Open the modal dialog routines at program start */
  391.  
  392.         do                                                                        /* Start of main event loop */
  393.         {
  394.  
  395.                 ApplLoop_Life();                                                /* Let into main loop */
  396.  
  397.                 Handle_User_Event();                                         /* Check for user events */
  398.  
  399.                 if (theInput != NIL)                                              /* See if a TE is active */
  400.                     TEIdle(theInput);                                             /* Blink the cursor if everything is ok */
  401.  
  402.                 if (WNE == TRUE)                                               /* See if do the MultiFinder way */
  403.                     DoIt = WaitNextEvent(everyEvent, &myEvent, SleepValue, NIL);/* Wait for an event */
  404.                 else
  405.                     {
  406.                         SystemTask();                                            /* For support of desk accessories */
  407.                         DoIt = GetNextEvent(everyEvent, &myEvent);/* See if an event is ready */
  408.                     }
  409.  
  410.                 ApplEvent_Life(&DoIt,&myEvent);                          /* Let us at the event first */
  411.  
  412.                 if (DoIt == TRUE)                                                /* If event then... */
  413.                     {                                                                /* Start handling the event */
  414.  
  415.                         Is_A_Dialog = IsDialogEvent(&myEvent);             /* See if a modeless dialog event */
  416.                         if (Is_A_Dialog == TRUE)                                /* Handle a dialog event */
  417.                             {
  418.                                  if (myEvent.what == updateEvt)                /* Handle the update of a Modeless Dialog */
  419.                                     {
  420.                                 whichWindow = (WindowPtr)myEvent.message; /* Get the window the update is for */
  421.                                 BeginUpdate(whichWindow);                     /* Set update clipping area */
  422.                                 Update_LIFE_WINDOW(whichWindow);          /* Update the modeless dialog */
  423.                                 EndUpdate(whichWindow);                        /* Return to normal clipping area */
  424.                                     }
  425.                                 else
  426.                                     {
  427.                                 DoTheModelessEvent = TRUE;                    /* Go ahead and do it so far */
  428.  
  429.                                 if (myEvent.what == keyDown)                  /* Check the key down, for a command key event */
  430.                                     {
  431.                                 CmdDown = ((myEvent.modifiers / cmdKey) & 1);/* Get the command key state */
  432.                                 charCode = myEvent.message & charCodeMask;/* Get the character */
  433.                                 ch = (char)charCode;                              /* Change it to ASCII */
  434.  
  435.                                 if ((charCode == 13) || (charCode == 0x03))/* CR or Enter */
  436.                                         DoTheModelessEvent = TRUE;             /* Handle the default selection */
  437.  
  438.                                 if (CmdDown != 0)                                 /* Handle if the command key was down */
  439.                                     {
  440.                                 mResult = MenuKey(ch);                          /* See if a menu selection */
  441.                                 theMenu = HiWord(mResult);                     /* Get the menu list number */
  442.                                 theItem = LoWord(mResult);                     /* Get the menu item number */
  443.                                 if (theMenu != 0)                                   /* See if a list was selected */
  444.                                         Handle_My_Menu(theMenu, theItem); /* Do the menu selection */
  445.  
  446.                                 whichWindow = FrontWindow();                  /* Get the front window */
  447.                                 if ((ch == 'x') || (ch == 'X'))                      /* Handle a CUT */
  448.                                         DlgCut(whichWindow);                      /* Do the dialog cut */
  449.                                 if ((ch == 'c') || (ch == 'C'))                      /* Handle a COPY */
  450.                                         DlgCopy(whichWindow);                    /* Do the dialog copy */
  451.                                 if ((ch == 'v') || (ch == 'V'))                      /* Handle a PASTE */
  452.                                         DlgPaste(whichWindow);                   /* Do the dialog paste */
  453.  
  454.                                 DoTheModelessEvent = FALSE;                   /* We handled the command key */
  455.                                     }
  456.                                     }
  457.  
  458.                                 if (DoTheModelessEvent == TRUE)               /* Do we handle it? */
  459.                                     {
  460.                                 if ((DialogSelect(&myEvent, &whichWindow, &itemHit)) || (myEvent.what == mouseDown) || (myEvent.what == keyDown)) /* Ck if do it */
  461.                                     {
  462.  
  463.                                 Do_LIFE_WINDOW(&myEvent,whichWindow,itemHit);/* Handle the Modeless Dialog */
  464.                                     }
  465.                                     }
  466.                                     }                                                   /* End of not update event */
  467.                             }                                                         /* End of Is_A_Dialog */
  468.                         else                                                         /* Otherwise handle a window */
  469.                             {
  470.  
  471.                                 switch (myEvent.what)                           /* Decide type of event */
  472.                                 {
  473.                                         case mouseDown :                           /* Mouse button pressed */
  474.                                 code = FindWindow(myEvent.where, &whichWindow);/* Get which window the event happened in */
  475.  
  476.                                 switch (code)                                       /* Decide type of event again */
  477.                                 {
  478.                                         case inMenuBar :                             /* In the menubar */
  479.                                 mResult = MenuSelect(myEvent.where);/* Do menu selection */
  480.                                 theMenu = HiWord(mResult);                     /* Get the menu list number */
  481.                                 theItem = LoWord(mResult);                     /* Get the menu list item number */
  482.                                 Handle_My_Menu( theMenu, theItem);         /* Handle the menu */
  483.                                 break;                                                /* End of inMenuBar */
  484.  
  485.                                         case inDrag :                                 /* In window drag area */
  486.                                                     DoDrag(whichWindow);            /* Go drag the window */
  487.                                                     break;                                /* End of InDrag */
  488.  
  489.                                         case inGrow :                                 /* In window grow area */
  490.                                                     DoGrow(whichWindow);           /* Handle the growing */
  491.                                                     break;                                /* End of inGrow */
  492.  
  493.                                         case inGoAway :                             /* In window goaway area */
  494.                                                     DoGoAway(whichWindow);/* Handle the goaway button */
  495.                                                     break;                                /* End of inGoAway */
  496.  
  497.                                         case inContent :                             /* In window  contents */
  498.                                                     DoInContent(whichWindow);/* Handle the hit inside a window */
  499.                                                     break;                                /* End of inContent */
  500.  
  501.                                         case inSysWindow :                         /* See if a DA selectio */
  502.                                                     SystemClick(&myEvent, whichWindow);/* Let other programs in */
  503.                                                     break;                                /* End of inSysWindow */
  504.  
  505.                                         default:                                        /* Handle others */
  506.                                                     break;                                /* End of otherwise */
  507.                                 }                                                      /* End of code case */
  508.                                                     break;                                /* End of MouseDown */
  509.  
  510.                                         case keyDown:                               /* Handle key inputs */
  511.                                         case autoKey:                                /* and auto repeats */
  512.                                                     DoKeyEvent();                      /* Get the key and handle it */
  513.                                                     break;                                /* End of otherwise */
  514.  
  515.                                         case updateEvt :                             /* Update event for a window */
  516.                                                     DoUpdate();                         /* Handle the update */
  517.                                                     break;                                /* End of otherwise */
  518.  
  519.                                         case diskEvt :                                /* Disk inserted event */
  520.                                                     DoDiskEvent();                     /* Handle a disk event */
  521.                                                     break;                                /* End of otherwise */
  522.  
  523.                                         case activateEvt :                           /* Window activated event */
  524.                                                     DoActivate();                       /* Handle the activation */
  525.                                                     break;                                /* End of otherwise */
  526.  
  527.                                         default:                                        /* Used for debugging, to see what other events are coming in */
  528.                                                     break;                                /* End of otherwise */
  529.  
  530.                                 }                                                      /* End of case */
  531.  
  532.                             }                                                         /* End for not a modeless dialog event */
  533.                     }                                                                /* end of GetNextEvent */
  534.                 else                                                               /* Blink cursor in modeless TEs */
  535.                     {
  536.                         whichWindow = FrontWindow();                        /* Get the current front window */
  537.                         if (whichWindow != NIL)                                 /* See if we have a window */
  538.                             {
  539.                                 thePeeked = (WindowPeek)whichWindow;/* Peek inside, look for dialog */
  540.                                 if (thePeeked->windowKind == dialogKind)/* DialogSelect will crash if no dialogs */
  541.                                     {
  542.                                 if (DialogSelect(&myEvent, &whichWindow, &itemHit))/* Blink cursor in modeless TEs */
  543.                                     {
  544.                                     }
  545.                                     }
  546.                             }
  547.                     }
  548.         }                                                                         /* end of while */
  549.         while (doneFlag == FALSE);                                         /* End of the event loop */
  550.  
  551.         ApplExit_Life();                                                       /* Handle extra program termination code */
  552.  
  553. }                                                                                /* end of main */
  554.